<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  function Cat(name, color) {
    // {}
    // this -> {}
    this.name = name;
    this.color = color;

    // this[[prototype]] = Cat.prototype;
    // this.__proto__ = Cat.prototype;
    // return this;
  }

  //  Cat.prototype 原型对象的本质是一个对象
  // Cat.prototype.constructor = Cat;
  Cat.prototype.species = "cat";
  Cat.prototype.call = function () {
    console.log("喵喵");
  }
  Cat.prototype.skill = function () {
    console.log("捉老鼠");
  }

  // 此方法虽然存在原型对象中, 但是调用时 是由实例化对象访问的 Tom.say() =>this指向调用此方法的实例化对象
  Cat.prototype.say = function () {
    console.log(this.name, this.color);
  }

  Object.prototype.hello = "你好";


  // 判断一个数据是否是纯对象?({a:1,b:2})
  var Tom = new Cat("Tom", "black");
  console.log(Tom);
  var obj = new Object({ a: 1, b: 2 });

  var arr = new Array(1, 2, 3, 4);
  var date = new Date()
  var reg = new RegExp();
  console.dir(arr);

  // console.log(Tom.toString());
  // console.log(obj.toString());
  // console.log(arr.toString());  // 有自己toStrin()  不会访问Object.prototype.toString()
  // console.log(date.toString()); // 有自己toStrin()  不会访问Object.prototype.toString()
  // console.log(reg.toString());  // 有自己toStrin()  不会访问Object.prototype.toString()

  console.log(Object.prototype.toString.call(Tom));
  console.log(Object.prototype.toString.call(obj));
  console.log(Object.prototype.toString.call(arr));
  console.log(Object.prototype.toString.call(date));
  console.log(Object.prototype.toString.call(reg));

  console.log(Object.prototype.toString.call(Tom) == "[object Object]");
</script>

</html>